from flask import Blueprint, request, jsonify
from service.informationService import *
from service import informationService

information_bp = Blueprint('information_bp', __name__)


@information_bp.route('/', methods=['GET'])
def get_information():
    return informationService.getInformation()


@information_bp.route('/<id>', methods=['GET'])
def get_informationById(id):
    return informationService.getInformationById(id)


@information_bp.route('/find/<id>/<sort>', methods=['GET'])
def get_informationBySort(id, sort):
    print(id)
    print(sort)
    return informationService.getinformationBySort(id, sort)


@information_bp.route('/', methods=['POST'])
def add_information():
    data = request.get_json()
    information = Information(data['id'], data['sort'], data['content'])
    return informationService.addInformation(information)
